package util;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JWindow;

public class ProgressFeedback extends JWindow{
	private static final long serialVersionUID = 1L;

	private JLabel jLabel;
	private JProgressBar bar;
	
	public ProgressFeedback(String text, int size) {
		setLayout(new BoxLayout(getContentPane(),BoxLayout.Y_AXIS));
		jLabel = new JLabel(text);
		bar = new JProgressBar(0,size);
		bar.setStringPainted(true);
		
		add(jLabel);
		add(bar);
		
		setAlwaysOnTop(true);
		setSize(getPreferredSize());
		setLocationRelativeTo(null);
		setVisible(true);
	}
	
	public void setMax(int setTo){
		bar.setMaximum(setTo);
	}
	
	public int getMaximum(){
		return bar.getMaximum();
	}
	
	public void setValue(int setTo) {		
		bar.setValue(setTo);
		if(bar.getMaximum()<=setTo){
			setVisible(false);
		}
	}
	
	public int getValue() {		
		return bar.getValue();
	}
}
